import traceback


ANSI_HELP = '''ANSI Color Format: \\033[{?}m (\\033: escape, {?}: code)
# Style code
- 0: clear all
- 1: bold
- 2: faint
- 3: italic
- 4: underline
- 5: blink(slow)
- 6: blink(fast)
- 7: reverse
- 8: erase
- 9: strikethrough
- 21~29: 1-9 off
# Foreground Colors code
- 30: black
- 31: red
- 32: green
- 33: yellow
- 34: blue
- 35: magenta
- 36: cyan
- 37: white
- 39: default
- 90~97: light 30~37
# Background Colors code
- 40~47: background 30~37
- 49: background default
- 100~107: background 90~97
'''

class Style:
    HELP = ANSI_HELP
    COLOR_NAME = [
        '黑色',
        '红色',
        '绿色',
        '黄色/棕色',
        '蓝色',
        '品红色/紫红色',
        '青蓝色/青色',
        '白色/亮灰色'
    ]

	# Foreground Colors
	## normal
    CX = C0 = BLACK   = '\033[30m'
    CR = C1 = RED     = '\033[31m'
    CG = C2 = GREEN   = '\033[32m'
    CY = C3 = YELLOW  = '\033[33m'
    CB = C4 = BLUE    = '\033[34m'
    CM = C5 = MAGENTA = '\033[35m'
    CC = C6 = CYAN    = '\033[36m'
    CW = C7 = WHITE   = '\033[37m'

	## hightlight
    HX = H0 = H_BLACK   = '\033[90m'
    HR = H1 = H_RED     = '\033[91m'
    HG = H2 = H_GREEN   = '\033[92m'
    HY = H3 = H_YELLOW  = '\033[93m'
    HB = H4 = H_BLUE    = '\033[94m'
    HM = H5 = H_MAGENTA = '\033[95m'
    HC = H6 = H_CYAN    = '\033[96m'
    HW = H7 = H_WHITE   = '\033[97m'

	# Background Colors
	## normal
    BX = B0 = B_BLACK   = '\033[40m'
    BR = B1 = B_RED     = '\033[41m'
    BG = B2 = B_GREEN   = '\033[42m'
    BY = B3 = B_YELLOW  = '\033[43m'
    BB = B4 = B_BLUE    = '\033[44m'
    BM = B5 = B_MAGENTA = '\033[45m'
    BC = B6 = B_CYAN    = '\033[46m'
    BW = B7 = B_WHITE   = '\033[47m'
	#hightlight
    HBX = HB0 = HB_BLACK   = '\033[100m'
    HBR = HB1 = HB_RED     = '\033[101m'
    HBG = HB2 = HB_GREEN   = '\033[102m'
    HBY = HB3 = HB_YELLOW  = '\033[103m'
    HBB = HB4 = HB_BLUE    = '\033[104m'
    HBM = HB5 = HB_MAGENTA = '\033[105m'
    HBC = HB6 = HB_CYAN    = '\033[106m'
    HBW = HB7 = HB_WHITE   = '\033[107m'

    SYTLE_NAME = [
        '粗体/高亮',
        '斜体/强调',
        '下划线',
        '闪烁',
        '反显/背景色和前景色反转',
        '消隐'
    ]

    SB = S0 = BOLD      = '\033[1m'
    SI = S1 = ITALIC    = '\033[3m'
    SU = S2 = UNDERLINE = '\033[4m'
    SBL = S4 = BLINK    = '\033[5m'
    SR = S5 = REVERSE   = '\033[7m'
    SE = S5 = ERASE     = '\033[8m'

	#reset
    N = RESET = '\033[0m'

    #defined style
    DS_UID = '\033[1;97m'


    f_uid = lambda x: Style.DS_UID + x + Style.N


    @staticmethod
    def escape(msg:str, end=True):
        msg = eval(f"f'{msg}'")
        return msg + Style.N if end else msg


if __name__ == '__main__':
	S = Style
	print(f'{S.C4}forground.Blue {S.B1}background.Red {S.N}no color')
